const express = require("express");
const app = express();
app.use(express.static("public"))


// function contt1(req, res, next) {

// }

app.use("/", (req, res, next) => {
    if (req.query.mag == 1) {
        next();
        // http://localhost:3060/test1?mag=1
    } else {
        res.send("哈哈哈哈哈")
        // http://localhost:3060/test1
    }
    console.log("已拦截请求")
})


app.get("/test1", (req, res) => {
    console.log("接收请求成功")
    res.send("服务器已接收请求")
})

//全局中间件


app.listen(3060, (err) => {
    if (!err) {
        console.log("SUCCEED")
    } else {
        console.log("FILED")
    }
})